import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },
  {
    path: '/basic',
    component: Layout,
    redirect: '/basic/notice',
    name: 'Basic',
    meta: {
      title: '基础设置',
      icon: 'setting'
    },
    alwaysShow: true,
    children: [
      {
        path: 'change',
        name: 'BasicChange',
        hidden: true,
        component: () => import('@/views/basic/change/index'),
        meta: { title: '修改密码' }
      },
      {
        path: 'notice',
        name: 'BasicNotice',
        component: () => import('@/views/basic/notice/index'),
        meta: { title: '公告管理' }
      },
      {
        path: 'vip',
        name: 'BasicVip',
        component: () => import('@/views/basic/vip/index'),
        meta: { title: '会员升级' }
      },
      {
        path: 'remind',
        name: 'BasicRemind',
        component: () => import('@/views/basic/remind/index'),
        meta: { title: '交易提醒' }
      },
      {
        path: 'services',
        name: 'BasicServices',
        component: () => import('@/views/basic/services/index'),
        meta: { title: '客服设置' }
      },
      {
        path: 'upgrade',
        name: 'BasicUpgrade',
        component: () => import('@/views/basic/upgrade/index'),
        meta: { title: '服务商升级设置' }
      },
      {
        path: 'publishPrice',
        name: 'BasicPublishPrice',
        component: () => import('@/views/basic/publishPrice/index'),
        meta: { title: '发布费用设置' }
      },
      {
        path: 'withdraw',
        name: 'BasicWithdraw',
        component: () => import('@/views/basic/withdraw/index'),
        meta: { title: '提现设置' }
      },
      {
        path: 'commission',
        name: 'BasicCommission',
        component: () => import('@/views/basic/commission/index'),
        meta: { title: '佣金比例设置' }
      },
      {
        path: 'card',
        name: 'BasicCard',
        component: () => import('@/views/basic/card/index'),
        meta: { title: '年卡设置' }
      },
      {
        path: 'type',
        name: 'BasicType',
        component: () => import('@/views/basic/type/index'),
        meta: { title: '类型设置' },
        children: [
          {
            path: 'detail',
            name: 'BasicTypeDetail',
            component: () => import('@/views/basic/type/detail/index'),
            meta: { title: '子类型详情' },
            hidden: true
          }
        ]
      }
    ]
  },
  {
    path: '/message',
    component: Layout,
    redirect: '/message/rent',
    name: 'Message',
    meta: {
      title: '信息管理',
      icon: 'message'
    },
    children: [
      {
        path: 'rent',
        component: () => import('@/views/message/publish/rent/index'),
        name: 'MessagePublishRent',
        meta: { title: '租赁信息' },
        children: [
          {
            path: 'detail',
            component: () => import('@/views/message/publish/rent/detail/index'),
            name: 'MessagePublishRentDetail',
            meta: { title: '租赁详情' },
            hidden: true
          }
        ]
      },
      {
        path: 'sell',
        component: () => import('@/views/message/publish/sell/index'),
        name: 'MessagePublishSell',
        meta: { title: '销售信息' },
        children: [
          {
            path: 'detail',
            component: () => import('@/views/message/publish/sell/detail/index'),
            name: 'MessagePublishSellDetail',
            meta: { title: '销售详情' },
            hidden: true
          }
        ]
      },
      {
        path: 'maintain',
        component: () => import('@/views/message/publish/maintain/index'),
        name: 'MessagePublishMaintain',
        meta: { title: '维修信息' },
        children: [
          {
            path: 'detail',
            component: () => import('@/views/message/publish/maintain/detail/index'),
            name: 'MessagePublishMaintainDetail',
            meta: { title: '维修详情' },
            hidden: true
          }
        ]
      },
      {
        path: 'report',
        component: () => import('@/views/message/report/index'),
        name: 'MessageReport',
        meta: { title: '举报信息' }
      },
      {
        path: 'suggest',
        component: () => import('@/views/message/suggest/index'),
        name: 'MessageSuggest',
        meta: { title: '反馈信息' }
      }
    ]
  },
  {
    path: '/statistics',
    component: Layout,
    redirect: '/statistics/order',
    name: 'Statistics',
    meta: {
      title: '业务统计',
      icon: 'nested'
    },
    children: [
      {
        path: 'order',
        component: () => import('@/views/statistics/order/index'),
        name: 'StatisticsOrder',
        meta: { title: '订单统计' }
      },
      {
        path: 'commission',
        component: () => import('@/views/statistics/commission/index'),
        name: 'StatisticsCommission',
        meta: { title: '佣金统计' }
      }
    ]
  },
  {
    path: '/vip',
    component: Layout,
    redirect: '/vip/list',
    name: 'Vip',
    meta: {
      title: '会员管理',
      icon: 'apply'
    },
    children: [
      {
        path: 'list',
        component: () => import('@/views/vip/list/index'),
        name: 'VipList',
        meta: { title: '会员列表' },
        children: [
          {
            path: 'detail/:id',
            component: () => import('@/views/vip/list/detail/index'),
            name: 'VipAgencyDetail',
            hidden: true,
            meta: { title: '会员详情' }
          }
        ]
      },
      // {
      //   path: 'agency',
      //   component: () => import('@/views/vip/agency/index'),
      //   name: 'VipAgency',
      //   meta: { title: '代理商列表' }
      // },
      {
        path: 'agencyAudit',
        component: () => import('@/views/vip/agencyAudit/index'),
        name: 'VipAgencyAudit',
        meta: { title: '代理商审核' }
      },
      {
        path: 'attestationRecord',
        component: () => import('@/views/vip/attestationRecord/index'),
        name: 'VipAttestation',
        meta: { title: '企业实名认证审核' }
      },
      {
        path: 'attestation',
        component: () => import('@/views/vip/attestation/index'),
        name: 'VipAttestationId',
        meta: { title: '个人实名认证审核' }
      }
    ]
  },
  {
    path: '/withdraw',
    component: Layout,
    redirect: '/withdraw/list',
    name: 'Withdraw',
    meta: {
      title: '提现管理',
      icon: 'deal'
    },
    children: [
      // {
      //   path: 'record',
      //   component: () => import('@/views/withdraw/record/index'),
      //   name: 'withdrawRecord',
      //   meta: { title: '提现记录' }
      // },
      {
        path: 'confirm',
        component: () => import('@/views/withdraw/confirm/index'),
        name: 'withdrawConfirm',
        meta: { title: '提现管理' }
      }
    ]
  },
  {
    path: '/safety',
    component: Layout,
    redirect: '/safety/user',
    name: 'Safety',
    meta: { title: '安全设置', icon: 'user' },
    children: [
      {
        path: 'user',
        component: () => import('@/views/safety/user/index'),
        name: 'SafetyUser',
        meta: { title: '管理员设置' }
      },
      {
        path: 'info/:id',
        component: () => import('@/views/safety/info/index'),
        hidden: true,
        name: 'SafetyInfo',
        meta: { title: '个人信息' }
      }
    ]
  },
  {
    path: '/dictionary',
    component: Layout,
    redirect: '/dictionary/detail',
    name: 'Dictionary',
    meta: {
      title: '数据管理',
      icon: 'tree'
    },
    children: [
      {
        path: 'detail',
        component: () => import('@/views/dictionary/index'),
        name: 'DictionaryDetail',
        meta: { title: '数据管理' }
      }
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
